<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%@ include file="/include/header.jsp"%>
<title>${basePageTitle}</title>
<link href="${baseURL}/css/um/register.css" rel="stylesheet" type="text/css" />
<link href="${baseURL}/css/um/default.css" rel="stylesheet" type="text/css" />
<link rev="stylesheet" href="${baseURL}/fare/css/form_style.css" type="text/css" rel="stylesheet">

<style type="text/css">
.cover{
	background:url('${baseURL}/images/tab_bg.png') repeat-x;
	height:25px;
	border-left:1px solid #C2D5EA;
	border-right:1px solid #C2D5EA;
	color:#383838;
}

li{
	line-height:25px;
	padding-left:0px;
	padding-right:0px;
	margin-left:15px;
	float:left;
	color:#383838;
	font-size:18px;
	
}
</style>
<script type="text/javascript">
head = document.getElementsByTagName("head")[0];
cssLink = document.createElement("link");
cssLink.rel = cssLink.rev = "stylesheet";
cssLink.type = "text/css";
cssLink.media = "screen";
head.appendChild(cssLink);
if ($.browser.msie) {
	(function() {
		var e = "article,aside,details,figure,footer,header,nav,section"
				.split(','), i = e.length;
		while (i--) {
			document.createElement(e[i]);
		}
	})();
	cssLink.href = "${baseURL}/css/download_ie.css";
} else {
	cssLink.href = "${baseURL}/css/download.css";
}
$(function(){
	$("span").click(function(){
		var hasChecked = $(this).prev().attr("checked");
		$(this).prev().attr("checked",!hasChecked);
	});
	var userName = "${param.userName}";
	$("#btn1").click(function(){
		var checkedLine= [];
		$("input[name='line']:checked").each(function() {
			checkedLine.push($(this).val());
        });
		//这里做一下控制，选太多的话系统暂不支持
		if(checkedLine.length==0){
			alert("<s:i18n name='careline'> <s:text name='careLine.register.alert.mustselected'></s:text></s:i18n>!");
			return false;
		}else if(checkedLine.length>20){
			alert("<s:i18n name='careline'> <s:text name='careLine.register.alert.morethan'></s:text></s:i18n>!");
			return false;
		}
		var url ="${baseURL}/usercareline/savelogin.action";
		var data= {"checkedLine":checkedLine.join(","),"userName": userName};
			 $.ajax({
					url:url,
					data:data,
					type : "POST",
					cache : false, 
					async : true,
				    dataType:'json',
				    success:function(data){
				    	if(data && data.hasOk){
				    		alert("<s:i18n name='careline'> <s:text name='careLine.register.alert.setsuccess'></s:text></s:i18n>。");
							window.location.href = baseURL+"/index.koala";
				    	}
				    }
			 });
	});
});
</script>

</head>
<body>
<header>
	<%@ include file="/include/start/start_header3.jsp" %>
</header>

<div id="center">
     <div class="register_content">
         <div class="register_content_top"></div>
         <div class="register_content_center">
            <h3 class="second_title"><s:i18n name='careline'><s:text name='careLine.register.title'></s:text></s:i18n></h3>
          <table align="center" id="carelinetable" border="0" cellpadding="0" cellspacing="0" width="100%" >
			<tr>
				<td align="left">
					<c:forEach var="k" items="${lineMaps}" varStatus="vsk">
						<h4 style="font-size:1.5em">${k.key}</h4>
						<hr style="border:1px dashed #BFCFE1;"></hr>
						<c:forEach var="o" items="${k.value}" varStatus="vs">
							<input type="checkbox" name="line" value="${o.id}"/>
							<span>${o.airLine}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<c:if test="${vs.count%3==0}"><br/></c:if>
						</c:forEach>
					</c:forEach>
				</td>
			</tr>	
		</table>
	<br />
	<br />
	<br />
    <input class="new_button_submit" id="btn1" value="<s:i18n name='careline'> <s:text name='careLine.register.title.addbutton'></s:text></s:i18n>" type="button" >
</div>
</div>
</div>
<footer>
	<%@ include file="/include/home/home_footer.jsp" %> 
</footer>
</body>
</html>
